import * as types from '../mutation-type'

let state = {
  name: '',
  phone: '',
  citys: '',
  cityDetails: '',
  address: '',
  num: '',
  goodsList: []
}

let getters = {
  name: state => state.name,
  phone: state => state.phone,
  citys: state => state.citys,
  cityDetails: state => state.cityDetails,
  address: state => state.address,
  num: state => state.num,
  goodsList: state => state.goodsList
}

let actions = {
  async getPosition ({commit, state}) {
    commit(types.RECORD_POSITION, state)
    // return
  }
}

let mutations = {
  [types.RECORD_POSITION] (state, datas) {
    state.name = datas.name
    state.phone = datas.phone
    state.citys = datas.citys
    state.cityDetails = datas.cityDetails
    state.address = datas.address
    state.num = datas.num
    state.goodsList = datas.goodsList

    window.localStorage.goodsList = datas.goodsList
    window.localStorage.num = datas.num
    window.localStorage.address = datas.address
  }
}
export default {
  state,
  getters,
  actions,
  mutations
}
